package com.os.sys.repository;

import com.os.sys.model.T_SYS_Role;
import com.os.sys.model.T_SYS_Role_To_User;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * Created by Administrator on 2017/6/14.
 */
public interface Role_To_UserRepository extends PagingAndSortingRepository<T_SYS_Role_To_User, Long>, JpaSpecificationExecutor<T_SYS_Role_To_User> {

    @Query("select t.roleId from T_SYS_Role_To_User t where t.userId=:userId")
    List<Long> findUserRoleIds(@Param("userId") Long userId);

    List<T_SYS_Role_To_User> findAllByUserId(Long userId);

    void deleteByUserIdAndRoleId(long userId, long roleId);
}
